﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using ESRI.ArcGIS.ADF.BaseClasses;
using ESRI.ArcGIS.ADF.CATIDs;
using ESRI.ArcGIS.Controls;
using ESRI.ArcGIS.Carto;
using ESRI.ArcGIS.Geodatabase;
using ESRI.ArcGIS.Geometry;
using ESRI.ArcGIS.SystemUI;


namespace ActivityInfo.ArcGIS.Tiles
{
    public partial class ZoomControl : UserControl
    {
        private IHookHelper hookHelper;

        public ZoomControl(IHookHelper hookHelper)
        {
            this.hookHelper = hookHelper;

            InitializeComponent();
        }

        private void ZoomControl_Load(object sender, EventArgs e)
        {
            for (int i = 0; i <= 16; ++i)
            {
                this.levelComboBox.Items.Add(string.Format("{0}", i));
            }
        }

        private void levelComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            TileCoordinateSystem tileCS = new TileCoordinateSystem(hookHelper.FocusMap);

            // calculate the new scale
            double targetScale = tileCS.ScaleForZoomLevel(levelComboBox.SelectedIndex);

            // calculate the ratio between the old scale and the new scale

            hookHelper.FocusMap.MapScale = targetScale;
            hookHelper.ActiveView.Refresh();
        }
    }
}
